<template>
  <!-- 设置 -->
  <view id="warp">
    <c-navBar title="设置" isSeat></c-navBar>
    <view class="info">
      <!-- <view class="items" @click="goDetail(2)">
				<view class="title">关于我们</view>
				<view class="detail">
					<image src="../../../static/common/go.png" class="arrow"></image>
				</view>
			</view> -->
      <view class="items" @click="goDetail(1)">
        <view class="title">用户协议</view>
        <view class="detail">
          <image src="../../../static/common/go.png" class="arrow"></image>
        </view>
      </view>
      <view class="items" @click="goDetail(2)">
        <view class="title">隐私协议</view>
        <view class="detail">
          <image src="../../../static/common/go.png" class="arrow"></image>
        </view>
      </view>
      <view class="items" @click="conShow = true">
        <view class="title">退出登陆</view>
        <view class="detail">
          <image src="../../../static/common/go.png" class="arrow"></image>
        </view>
      </view>
      <!-- <view class="items" @click="goDetail(5)">
        <view class="title">客服</view>
        <view class="detail">
          <image src="../../../static/common/go.png" class="arrow"></image>
        </view>
      </view> -->
    </view>

    <c-confirmPop
      :show="conShow"
      title="退出登录"
      text="是否退出当前登录账号?"
      @confirm="definiteExit"
      @close="conShow = false"
    ></c-confirmPop>
  </view>
</template>

<script>
export default {
  data() {
    return {
      conShow: false,
    };
  },
  methods: {
    openPdf(url) {
      uni.downloadFile({
        url: url,
        success: function (res) {
          console.log(res, "res");
          let filePath = res.tempFilePath;
          uni.openDocument({
            filePath: filePath,
            showMenu: true,
            success: function (res) {
              // console.log('打开文档成功');
              console.log(res, "打开文档成功");
              uni.hideLoading();
            },
          });
        },
        fail(err) {
          console.log("打开文档失败", err);
          uni.hideLoading();
        },
      });
    },

    // 跳转到协议
    goDetail(num) {
      if (num == 5) {
        uni.navigateTo({
          url: "/pages/my/pages/service",
        });
      } else if (num == 1) {
        this.$api.userAgreement({}).then((res) => {
          console.log(res, "用户协议");
          this.userAgreement = res.data;
          this.openPdf(res.data);
        });
      } else if (num == 2) {
        this.$api.getAgreement({}).then((res) => {
          console.log(res, "隐私协议");
          this.getAgreement = res.data;
          this.openPdf(res.data);
        });
      } else {
        uni.navigateTo({
          url: "/pages/tabbar/agreement?type=" + num,
        });
      }
    },
    // 确定退出
    definiteExit() {
		this.$u.vuex("vuex_token", null)
      uni.clearStorageSync();
      uni.reLaunch({
        url: "/pages/tabbar/login",
        fail: (err) => {
          console.log("err", err);
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
#warp {
  position: relative;
  width: 100%;
  min-height: 100vh;
  padding-top: 200rpx;
  box-sizing: border-box;
  background-color: #ffffff;

  .info {
    border-radius: 16rpx;
    padding: 0 30rpx;

    .items {
      box-sizing: border-box;
      border-bottom: 1rpx solid #e6e6e6;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20rpx 0;

      .title {
        width: 300rpx;
        color: #333333;
        font-size: 28rpx;
        font-family: PingFang SC-Medium;
      }

      .detail {
        .arrow {
          margin-left: 13rpx;
          margin-top: 7rpx;
          width: 25rpx;
          height: 25rpx;
        }
      }
    }
  }
}
</style>
